package org.jeecg.modules.nurse_user.service.impl;

import org.jeecg.modules.nurse_user.entity.NurseUserFamily;
import org.jeecg.modules.nurse_user.mapper.NurseUserFamilyMapper;
import org.jeecg.modules.nurse_user.service.INurseUserFamilyService;
import org.springframework.stereotype.Service;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Description: 用户监护人
 * @Author: jeecg-boot
 * @Date: 2024-06-09
 * @Version: V1.0
 */
@Service
public class NurseUserFamilyServiceImpl extends ServiceImpl<NurseUserFamilyMapper, NurseUserFamily> implements INurseUserFamilyService {

    @Autowired
    private NurseUserFamilyMapper nurseUserFamilyMapper;

    @Override
    public List<NurseUserFamily> selectByMainId(String mainId) {
        return nurseUserFamilyMapper.selectByMainId(mainId);
    }
    
    /**
     * 根据id获取anfineid序列值并更新实体
     * 
     * @param id 主键id
     * @return 更新后的实体对象
     */
    public NurseUserFamily updateAnfineidById(String id) {
        // 获取anfineid序列值
        String anfineid = nurseUserFamilyMapper.selectAnfineidById(id);
        
        // 更新实体的anfineid字段
        NurseUserFamily entity = new NurseUserFamily();
        entity.setId(id);
        entity.setAnfineid(anfineid);
        this.updateById(entity);
        
        // 返回更新后的完整实体
        return this.getById(id);
    }
}